home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
cstdio.arc
/
SRC.ARC
/
ATOI.C
next >
Wrap
C/C++ Source or Header
|
1984-07-29
|
474b
|
24 lines
/* atoi.c - ASCII to integer conversion.
K & R page 58, using pointers.
Entered - G. R. Mansfield. 84/06/06.
Ver 1.0-4729.
*/
#include <defstd.h>
#include <ctype.h>
atoi(s) /* convert s to integer n */
char *s;
{
int i, n, sign;
while (isspace(*s)) /* skip white space */
s++;
sign = 1;
if (*s == '+' || *s == '-') /* sign */
sign = (*s++ == '+') ? 1 : -1;
for (n = 0; isdigit(*s); s++)
n = n * 10 + (*s - '0');
return(sign * n);
}